/**
 * <copyright>
 * Copyrigth 2007 Aurelien Moreau
 *
 * This file is part of ProcessShop.
 *
 * ProcessShop is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * ProcessShop is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with ProcessShop; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 * </copyright>
 *
 * $Id$
 */
package net.yienyien.process.bpd.util;

import java.io.IOException;

import net.yienyien.process.bpd.BPDModel;
import net.yienyien.process.bpd.BpdFactory;
import net.yienyien.process.bpd.BpdPackage;
import net.yienyien.process.bpd.ControlFlowRelation;
import net.yienyien.process.bpd.EndEvent;
import net.yienyien.process.bpd.StartEvent;
import net.yienyien.process.bpd.Task;

import org.eclipse.emf.common.util.URI;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.ecore.resource.ResourceSet;
import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.xmi.impl.XMIResourceFactoryImpl;

public class Test {
	
	public static void main(String[] args) {
		
		BpdPackage.eINSTANCE.eClass();
		
		BPDModel model=BpdFactory.eINSTANCE.createBPDModel();
		
		StartEvent start=BpdFactory.eINSTANCE.createStartEvent();
		model.getObjects().add(start);

		Task task1=BpdFactory.eINSTANCE.createTask();
		model.getObjects().add(task1);
		
		ControlFlowRelation cf1=BpdFactory.eINSTANCE.createControlFlowRelation();
		cf1.setInput(start);
		cf1.setOutput(task1);
		model.getRelations().add(cf1);
		
		Task task2=BpdFactory.eINSTANCE.createTask();
		model.getObjects().add(task2);
		
		ControlFlowRelation cf2=BpdFactory.eINSTANCE.createControlFlowRelation();
		cf2.setInput(task1);
		cf2.setOutput(task2);
		model.getRelations().add(cf2);

		
		EndEvent end=BpdFactory.eINSTANCE.createEndEvent();
		model.getObjects().add(end);
		
		ControlFlowRelation cf3=BpdFactory.eINSTANCE.createControlFlowRelation();
		cf3.setInput(task2);
		cf3.setOutput(end);
		model.getRelations().add(cf3);
		
		
		/*
		model.getRelations().remove(cf1);
		model.getObjects().remove(task1);
		model.getRelations().remove(cf2);
		*/
	
		ResourceSet set=new ResourceSetImpl();
		set.getResourceFactoryRegistry().getExtensionToFactoryMap().put("xml", new XMIResourceFactoryImpl());
		Resource res=set.createResource(URI.createFileURI("/tmp/resource.tmp.xml"));
		res.getContents().add(model);
		
		try {
			res.save(System.out, null);
		} catch (IOException e) {
			e.printStackTrace();
		}
		
	}
	
	
	
}
